package org.example.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.example.bean.Course;
import org.example.mapper.CourseMapper;
import org.example.service.CourseService;
import org.example.util.JsonResult;
import org.example.util.ResultTool;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

/**
 * @Auther:Liu
 * @Testname:CourseServiceImpl
 * @Date:2025/9/9 11:36
 */
@Service
public class CourseServiceImpl extends ServiceImpl<CourseMapper, Course> implements CourseService {
    /**
     * 添加对象
     *
     * @param course
     * @return
     */
    @Override
    public JsonResult SaveCourse(Course course) {
        save(course);
        return ResultTool.success("添加成功");
    }

    /**
     * 查询数据
     * @param id
     * @return
     */
    @Cacheable(cacheNames = "findCourseById")
    public JsonResult findCourseById(String id) {
        return ResultTool.success(getById(id));
    }
}
